{extend name="public/base" /}

{block name="seo"}
<title>{$title|default='标题'}</title>
<meta name="keywords" content="{$keywords|default='关键字'}">
<meta name="description" content="{$desc|default='描述'}">
</head>
<body>
{/block}

{block name='header'}{/block} {//关掉头部}
{block name='menu'}{/block} {//关掉菜单}

{block name='content'}
<article class="cl pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-grade-edit">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班级：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$grade_info.name}" placeholder="grade" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学制：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" autocomplete="off" value="{$grade_info.length}" placeholder="length" id="length" name="length">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学费：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="price" name="price" id="price" value="{$grade_info.price}">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">启用状态：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
				<select class="select" name="status" size="1" id="status">
					{if condition="$grade_info.status eq '1'"}
					<option value="1" selected>启用</option>
                    <option value="0">停用</option>
					{else /}
					<option value="0" selected>停用</option>
                    <option value="1">启用</option>
					{/if}
				</select>
				</span>
			</div>
		</div>
		<!--隐藏表单记录id-->
		<input type="hidden" value="{$grade_info.id}" name="id" id="id">
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" id="submit" >
			</div>
		</div>
	</form>
	<form type="hidden">
		<input type="hidden" value="{$grade_info.name}" name="name_h" id="name_h">
		<input type="hidden" value="{$grade_info.length}" name="length_h" id="length_h">
		<input type="hidden" value="{$grade_info.price}" name="price_h" id="price_h">
		<input type="hidden" value="{$grade_info.status}" name="status_h" id="status_h">
	</form>
</article>
{/block}


<!--请在下方写此页面业务相关的脚本-->
{block name="js"}
<!--<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script> -->
<!--<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script> -->
<!--<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script> -->
<script type="text/javascript">
$(function(){
    //防止用户无更新提交，只有表中数据有变化时才允许提交
    // $("form").children().change(function () {
		// $("#submit").removeClass("disabled");
    // });

	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});

	$('#submit').click(function () {
        var form = {
            'id' : $('#id').val()
		};
        if(($('#name').val() == $('#name_h').val()) && ($('#length').val() == $('#length_h').val()) && ($('#price').val() == $('#price_h').val()) && ($('#status option:selected').val() == $('#status_h').val())) {
            alert('未做任何修改');
            return;
        }else {
            if ($('#name').val() != $('#name_h').val()) {
	            form.name = $('#name').val();
			}else if ($('#length').val() != $('#length_h').val()) {
				form.length = $('#length').val();
			}else if($('#price').val() != $('#price_h').val()){
                form.price = $('#price').val();
			}else if($('#status option:selected').val() == $('#status_h').val()) {
                form.status = $('#status option:selected').val();
			}
		}

		$.ajax({
			type:'POST',
			url:'/index/grade/updateGrade',
			data:form,
			dataType:'json',
			success:function (data) {
				if (data.status == 1){
				    alert(data.message);
				} else{
                    alert(data.message);
				}
            }
		});
    });

});
</script>
{/block}
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>